import bagel.Image;
import bagel.util.Point;
import bagel.util.Rectangle;
import bagel.util.Colour;
import bagel.Drawing;

public class Hammer {
    private Point position;
    private Image image;
    private double width,height;

    public Hammer(Point position,String imagePath) {
        this.position = position;
        this.image = new Image(imagePath); // 加载图像
        width = image.getWidth();
        height = image.getHeight();
    }

    public Point getPosition() {
        return position;
    }

    public Image getImage() {
        return image;
    }

    public void render() {
        image.draw(position.x, position.y);

        /*
        // 计算碰撞箱的四个角的坐标
        double left = position.x - width / 2;
        double right = position.x + width / 2;
        double top = position.y - height / 2;
        double bottom = position.y + height / 2;
        Point lt = new Point(left,top);
        Point rt = new Point(right,top);
        Point lb = new Point(left,bottom);
        Point rb = new Point(right,bottom);

        // 绘制矩形的四条边
        Drawing.drawLine(lt,rt,1, Colour.RED); // 上边
        Drawing.drawLine(rt,rb, 1,Colour.RED); // 右边
        Drawing.drawLine(rb,lb, 1,Colour.RED); // 下边
        Drawing.drawLine(lb,lt, 1,Colour.RED); // 左边
         */
    }
    public Rectangle getBoundingBox() {
        return new Rectangle(position.x-width/2, position.y-height/2, width,height);
    }
    public double getHeight(){
        return height;
    }
}